package com.rajaev.dtu.tractor.infrastructure.config;

import com.mongodb.MongoClient;

import com.rajaev.dtu.tractor.infrastructure.config.mongo.codec.BmsDailyResultCodec;
import com.rajaev.dtu.tractor.infrastructure.config.mongo.codec.BmsHourlyResultCodec;
import org.bson.codecs.configuration.CodecRegistries;
import org.bson.codecs.configuration.CodecRegistry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Created with IDEA
 * @author: tianjie
 * @Date:2019/6/19
 * @Time:15:43
 */
@Configuration
public class MongoCodecConfig {


    @Bean
    public CodecRegistry codecRegistry(){
        CodecRegistry codecRegistry = CodecRegistries
                .fromRegistries(CodecRegistries.fromCodecs(new BmsDailyResultCodec(), new BmsHourlyResultCodec()), MongoClient.getDefaultCodecRegistry());
        return codecRegistry;
    }
}
